<div class="content last ui-widget-content">
	<div class="content-full">
		<div style="width: 98%;padding-left: 5px;">
			<?php if (count($this->arrError)>0) echo $this->error($this->arrError); ?>
			<div class="cms_table">
				<?php if ($this->Obj['isupdate'] == 0){?>
						<h2>Thêm mới người dùng</h2>
						<?php }?>
				<?php if ($this->Obj['isupdate'] == 1){?>
						<h2>Chỉnh sửa thông tin người dùng</h2>
						<?php }?>
				<form action="<?php echo BASE_URL; ?>/<?php echo $this->controller;?>/<?php echo $this->action;?>"	method="POST" name="quiz-form" id="">
					<input type="hidden" name="id" value="<?php echo $this->Obj['id'] ;?>">		
					<input type="hidden" name="isupdate" value="<?php echo $this->Obj['isupdate'];?>"/>			
					<table cellpadding="0" cellspacing="0">
						<tr><td colspan="2" style="text-align: right;">	
							<span class="btnShowHideDetail">
								<input type="button" class="toggle-text-user"  value="Ẩn hiển thị chi tiết" onclick="hideDetail();">
							</span> 
							
						</td></tr>
						<tr><td class="label">
								Tên đăng nhập:
								</td><td class="field_container">
								<input id="username" type="text" onchange="validateUsername(); return false;" name="username" style="width: 300px "   value="<?php  echo $this->Obj['username']; ?>" ><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
								<div id="validateUserName" style="display: block;" class="errorMgStyle"></div>
						</td></tr>
						<tr><td class="label">
								Mật khẩu:
								</td><td class="field_container"><input type="text" name="password"  style="width: 200px "   value="<?php  echo $this->Obj['password']; ?>" ><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
						</td></tr>
						<tr><td class="label">
								Nhóm người dùng:
								</td><td class="field_container"><?php echo $this->SltGroupUser("group_id", $this->Obj['group_id']); ?><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
						</td></tr>
						<tr><td class="label">
								Mã số sinh viên hoặc giảng viên:
								</td><td class="field_container">
								<input id="user_code" type="text" onchange="validateUserCode(); return false;" name="user_code"  style="width: 200px "   value="<?php  echo $this->Obj['user_code']; ?>" ><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
								<div id="validateUserCode" style="display: block;" class="errorMgStyle"></div>
						</td></tr>
						<tr><td class="label">
								Họ:
								</td><td class="field_container"><input type="text" name="firstname"  style="width: 200px "   value="<?php  echo $this->Obj['firstname']; ?>" ><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
						</td></tr>
						<tr><td class="label">
								Tên:
								</td><td class="field_container"><input type="text" name="lastname"  style="width: 200px "   value="<?php  echo $this->Obj['lastname']; ?>" ><span class="inputRequestFillNotBlank"><font  color="red">*</font></span>
						</td></tr>
						 <tbody class="show-hide-detail">
							<tr><td class="label">
									Email:
									</td><td class="field_container"><input type="text" name="email"  style="width: 200px "   value="<?php  echo $this->Obj['email']; ?>" >
							</td></tr>
							<tr><td class="label">
									Yahoo:
									</td><td class="field_container"><input type="text" name="yahoo"  style="width: 200px "   value="<?php  echo $this->Obj['yahoo']; ?>" >
							</td></tr>
							<tr><td class="label">
									Skyper:
									</td><td class="field_container"><input type="text" name="skyper"  style="width: 200px "   value="<?php  echo $this->Obj['skyper']; ?>" >
							</td></tr>
							<tr><td class="label">
									Phone:
									</td><td class="field_container"><input type="text" name="phone"  style="width: 200px "   value="<?php  echo $this->Obj['phone']; ?>" >
							</td></tr>
							<tr><td class="label">
									Khoa: 
									</td><td class="field_container"><input type="text" name="department"  style="width: 200px "   value="<?php  echo $this->Obj['department']; ?>" >
							</td></tr>
							<tr><td class="label">
									Địa chỉ:
									</td><td class="field_container"><input type="text" name="address"  style="width: 200px "   value="<?php  echo $this->Obj['address']; ?>" >
							</td></tr>
							<tr><td class="label">
									Thành phố: 
									</td><td class="field_container"><input type="text" name="city"  style="width: 200px "   value="<?php  echo $this->Obj['city']; ?>" >
							</td></tr>
						 </tbody>
						<tr><td class="label">
									Khóa tài khoản này:
									</td><td class="field_container"><input type="checkbox" name="isblock" <?php if($this->Obj['isblock']==1) echo "checked"; ?> >
						</td></tr>
						
						<tr><td colspan="2"  style="font-size: 12px; color: white; font-family: tahoma;"  >
							<p align="center">
								<input  type="submit" value="Đồng ý" style="font-size: 15px;" class="add-answer-icon ui-state-default ui-corner-all">&nbsp;&nbsp;&nbsp;&nbsp;
								<input  type="button" value="Hủy bỏ" onclick="window.location='<?php echo  BASE_URL.'/user';  ?>'" style="font-size: 15px;" class="add-answer-icon ui-state-default ui-corner-all">
							</p>
						</td></tr>
						
					</table>		
				</form>
				<!--  -->
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
	function hideDetail(){
		$(".show-hide-detail").toggle("slow");
		var html='<input type="button" class="toggle-text-user" value="Hiển thị chi tiết" onclick="showDetail();">';
		$(".btnShowHideDetail").html(html);
	}
	function showDetail(){
		$(".show-hide-detail").toggle("slow");
		var html='<input type="button" class="toggle-text-user"  value="Ẩn hiển thị chi tiết" onclick="hideDetail();">';
		$(".btnShowHideDetail").html(html);
	}
		
	function validateUserCode(){
		 var user_code = $("#user_code").val();
		 var html = '';
		  if(user_code.length==0 || user_code.length<5){
		  	html = '<div id="validateUserCode" style="display: block;" class="errorMgStyle">Mã số phải từ 5 ký tự trở lên. </div>';
		  	$("#validateUserCode").html(html);
		  }else{
	  				$.ajax({
	    					   type: "POST",
	    					   url: $("#BASE_URL").val()+"/register/validateusercode",
	    					   data: "user_code="+user_code,
	    					   dataType: "json",
	    					   success: function(data){
	    						 if(data['success']==true)
	    							 html='<div id="validateUserCode" style="display: block;" class="okMgStyle">'+data["messageShow"]+'</div>';
	    						 else
	    							html='<div id="validateUserCode" style="display: block;" class="errorMgStyle">'+data["messageShow"]+'</div>';
	    							
	    						$("#validateUserCode").html(html);
	    					   }
	    					 }); 
	    	}
	}
	
	function validateUsername(){
		 var username = $("#username").val();
		 var html = '';
		  if(username.length==0 || username.length<3){
		  	html = '<div id="validateUserName" style="display: block;" class="errorMgStyle">Tên tài khoản không hợp lệ. </div>';
		  	$("#validateUserName").html(html);
		  }else{
	  				$.ajax({
	    					   type: "POST",
	    					   url: $("#BASE_URL").val()+"/register/validateusername",
	    					   data: "username="+username,
	    					   dataType: "json",
	    					   success: function(data){
	    						 if(data['success']==true)
	    							 html='<div id="validateUserName" style="display: block;" class="okMgStyle">'+data["messageShow"]+'</div>';
	    						 else
	    							 html='<div id="validateUserName" style="display: block;" class="errorMgStyle">'+data["messageShow"]+'</div>';
	    							
	    						$("#validateUserName").html(html);
	    					   }
	    					 }); 
	    	}
	}
	
		
</script>
